package com.ruoyi.web.core.config;

import com.ruoyi.web.vo.CommandResultVo;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * Created by admin on 2025/6/13.
 */
public class CommandResultUtil {

    public static CommandResultVo convertCommandResultVo(List<String> results){
        CommandResultVo commandResultVo = new CommandResultVo();
        for(String result : results){
            if (result.startsWith("###")) {
                commandResultVo.setRightResult(result);
            }else if (result.startsWith("!!!") && result.endsWith("!!!")) {
                commandResultVo.setErrorResult(result.replaceAll("!!!",""));
            }else{
                commandResultVo.addOtherResult(result);
            }
        }
        return commandResultVo;
    }

    public static CommandResultVo convertCommandResultVo(String result){
          return convertCommandResultVo(Arrays.asList(result));
    }
}
